package com.aixx.springcloud.alibaba.service.impl;

import com.aixx.springcloud.alibaba.dao.AccountDao;
import com.aixx.springcloud.alibaba.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * @author shkstart
 * @create 2021-02-18 14:49
 */
@Service
public class AccountServiceimpl implements AccountService {
    @Resource
    private AccountDao accountDao;



    @Override
    public void decrease(Long userid, BigDecimal money) {
        //暂停20秒
        try {
            TimeUnit.SECONDS.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        accountDao.decrease(userid, money);
    }
}
